<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>

<html>
<head>
    <script type="text/javascript">
        //遍历数组
        var color = ['gold','yellow','orange','blue']
        $.each(color,function (k, v) {
            console.log(k+'-----'+v)
        })
        //遍历对象
        //$.each(对象,function(k成员名称,v成员值){})
        var cat = {name:'kitty',color:'white',climb:function () {
            console.log('climb')
        }}
        $.each(cat,function (k, v) {
            console.log(k+'----'+v)
        })
        window.onload = function () {
            //遍历jquery对象
            //$().each(function(k-dom对象下标，v-dom对象
            $('li').each(function (k, v) {
                console.log(k+'---'+v)
                this.style.color = 'purple';
                $(this).css('background-color','pink')
//                v.style.color = 'blue'//对dom对象进行样式设置
//                $(this).css('background-color','lightgreen')//dom对象编程jquery对象
            })

        }
    </script>
</head>
<body>
    <div>
        <ul>
            <li>A</li>
            <li>B</li>
            <li>C</li>
            <li>D</li>
        </ul>
    </div>
</body>
</html>
